<template>
	<view class="">
		<view class="mnemonic-content">
			{{mnemonic || '--'}}
		</view>
		
		<view class="copy-btn">
			<button type="default" hover-class="active" @tap.stop="copy">{{i18n.Copy_backup}}</button>
		</view>
		
	</view>
</template>

<script>
	import {fetch, showToast, pageto, forceUpdate, check_login} from '@/common/js/util.js'
	import {mapGetters} from 'vuex' 
	export default {
		data() {
			return {
				mnemonic:'',
				isfast:false
			}
		},
		computed: {
			i18n() {
				return this.$t('message')
			},
			...mapGetters([
				'getRequestUrl',
				'getLang',
				'getLogin',
				'getLoginInfo'
			])
		},
		onShow(){
			uni.setNavigationBarTitle({
				title:this.getLang==1?'备份助记词':'Backup mnemonic'
			})
			this.isfast=false;
		},
		onLoad(e){
			this.mnemonic = e.info
			console.log(e);
		},
		methods:{
			copy(){
				if (this.isfast) return;
				this.isfast = true;
				setTimeout(()=> {
					this.isfast = false;
				}, 1500)
				let  _this = this;
				uni.setClipboardData({
					data: this.mnemonic,
					success: function () {
						showToast(this.getLang==1?"复制成功":'Copy successfully')
						return
						uni.showModal({
							title: _this.i18n.copy_success,
							content:  _this.i18n.copy_success_message, 
							showCancel:false,
							success: function(res) {
								if (res.confirm) {											 
									//console.log('用户点击确定');
								} else if (res.cancel) {
									//console.log('用户点击取消');
								}
							}
						});
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.mnemonic-content{
		background: #F5F6F8;
		margin: 100rpx 30rpx;
		padding: 40rpx 20rpx 100rpx;
		border-radius: 20rpx;
		font-size: 26rpx;
		word-break: break-word;
	}
	.copy-btn{
		button{
			background: #2C385C;
			width: 280rpx;
			height: 74rpx;
			line-height: 74rpx;
			padding: 0;
			border-radius: 10rpx;
			color: #FFFFFF;
			font-size: 26rpx;
			&.active{
				background: #D1D1D1 !important;
			}
		}
	}
</style>
